package com.j2eefast.flowable.bpm.service;


import cn.hutool.core.util.IdUtil;
import com.j2eefast.flowable.bpm.entity.bpmCrmTransferEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmTransferMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 过户Service接口
 * @author: yhli
 * @date 2020-06-28 21:20
 */
@Service
public class bpmCrmTransferService extends ServiceImpl<bpmCrmTransferMapper,bpmCrmTransferEntity> {

	@Resource
	private bpmCrmTransferMapper bpmCrmTransferMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmTransferEntity> queryWrapper = new QueryWrapper<bpmCrmTransferEntity>();
              String saleCode = (String) params.get("saleCode");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleCode), "sale_code", saleCode);
                               String saleUserid = (String) params.get("saleUserid");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleUserid), "sale_userid", saleUserid);
          String saleOrderNumber = (String) params.get("saleOrderNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleOrderNumber), "sale_order_number", saleOrderNumber);
          String outCarVin = (String) params.get("outCarVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVin), "out_car_vin", outCarVin);
          String outCarVehicle = (String) params.get("outCarVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVehicle), "out_car_vehicle", outCarVehicle);
          String orderSpecialRemark = (String) params.get("orderSpecialRemark");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderSpecialRemark), "order_special_remark", orderSpecialRemark);
          String orderCashierReview = (String) params.get("orderCashierReview");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderCashierReview), "order_cashier_review", orderCashierReview);
          String orderFinanceManagerReview = (String) params.get("orderFinanceManagerReview");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderFinanceManagerReview), "order_finance_manager_review", orderFinanceManagerReview);
          String orderCustomerSsn = (String) params.get("orderCustomerSsn");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderCustomerSsn), "order_customer_ssn", orderCustomerSsn);
          String orderCustomerIFilepath = (String) params.get("orderCustomerIFilepath");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderCustomerIFilepath), "order_customer_i_filepath", orderCustomerIFilepath);
          String orderRegistrantName = (String) params.get("orderRegistrantName");
        queryWrapper.like(ToolUtil.isNotEmpty(orderRegistrantName), "order_registrant_name", orderRegistrantName);
          String orderRegistrantAddress = (String) params.get("orderRegistrantAddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderRegistrantAddress), "order_registrant_address", orderRegistrantAddress);
          String orderRegistrantPhone = (String) params.get("orderRegistrantPhone");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderRegistrantPhone), "order_registrant_phone", orderRegistrantPhone);
          String orderIsNeedMail = (String) params.get("orderIsNeedMail");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderIsNeedMail), "order_is_need_mail", orderIsNeedMail);
          String orderRecipientisregistrant = (String) params.get("orderRecipientisregistrant");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderRecipientisregistrant), "order_recipientisregistrant", orderRecipientisregistrant);
          String orderRecipientName = (String) params.get("orderRecipientName");
        queryWrapper.like(ToolUtil.isNotEmpty(orderRecipientName), "order_recipient_name", orderRecipientName);
             String orderRecipientPhone = (String) params.get("orderRecipientPhone");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderRecipientPhone), "order_recipient_phone", orderRecipientPhone);
             String taxAmount = (String) params.get("taxAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(taxAmount), "tax_amount", taxAmount);
          String taxServiceCharge = (String) params.get("taxServiceCharge");
         queryWrapper.eq(ToolUtil.isNotEmpty(taxServiceCharge), "tax_service_charge", taxServiceCharge);
          String taxFreight = (String) params.get("taxFreight");
         queryWrapper.eq(ToolUtil.isNotEmpty(taxFreight), "tax_freight", taxFreight);
          String taxShippingInfo = (String) params.get("taxShippingInfo");
         queryWrapper.eq(ToolUtil.isNotEmpty(taxShippingInfo), "tax_shipping_info", taxShippingInfo);
          String taxTransferDate = (String) params.get("taxTransferDate");
         queryWrapper.eq(ToolUtil.isNotEmpty(taxTransferDate), "tax_transfer_date", taxTransferDate);
     		Page<bpmCrmTransferEntity> page = bpmCrmTransferMapper.selectPage(new Query<bpmCrmTransferEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmTransferEntity bpmCrmTransferEntity) {
		Page<bpmCrmTransferEntity> page = bpmCrmTransferMapper.findPage(new Query<bpmCrmTransferEntity>(params).getPage(), bpmCrmTransferEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmTransferByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmTransferById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmTransfer(bpmCrmTransferEntity bpmCrmTransfer){
        bpmCrmTransfer.setId(IdUtil.fastSimpleUUID());
        return save(bpmCrmTransfer);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmTransferById(bpmCrmTransferEntity bpmCrmTransfer) {
		return updateById(bpmCrmTransfer);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmTransferEntity getbpmCrmTransferById(String id){
		return getById(id);
	}
}
